package cn.com.cennavi.fileMake;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * 小文件合并
 * 
 * @author Thinkpad
 *
 */
public class FilesCombine {
	static String listFiles = "D:\\data\\TrafficLightCrossMap_beijingGroundRoad\\TrafficLightCrossMap";
	static String outFile = "D:\\data\\TrafficLightCrossMap_beijingGroundRoad\\combine.csv";

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		combine(listFiles, outFile);
	}

	private static void combine(String inputfilefolder2, String closeroadmapdatafile2) throws IOException {
		// TODO Auto-generated method stub
		File[] files = new File(inputfilefolder2).listFiles();
		BufferedWriter write = new BufferedWriter(new FileWriter(new File(closeroadmapdatafile2)));
		HashMap<String, String> dataMap = new HashMap<>();
		for (File file : files) {
			System.out.println(file.getName());
			BufferedReader br = new BufferedReader(new FileReader(file));
			String line = "";
			while ((line = br.readLine()) != null) {
				write.write(line);
				if(line.contains("561433")){
					String[] arr = line.split(":");
					System.out.println(arr[1] + "_" + arr[7] + "_" + arr[9]);
				}
				write.newLine();
				write.flush();
//				String[] arr = line.split(":");
//				String pointID_angle_flag = arr[1] + "_" + arr[7] + "_" + arr[9];
//				dataMap.put(pointID_angle_flag, line);
			}
			br.close();
			br = null;
		}
//		BufferedWriter write = new BufferedWriter(new FileWriter(new File(closeroadmapdatafile2)));
//		for (Map.Entry<String, String> entry : dataMap.entrySet()) {
//			write.write(entry.getValue());
//			write.newLine();
//			write.flush();
//		}
		write.close();
		write = null;
	}

}
